package com.ws.entity;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author 王硕
 * @version jdk21
 * @className Person
 * @description
 * @date 2024/11/6 19:26
 */
@Data
@Accessors(chain = true)
public class Person {
    private int id;
    private String name;
    private int age;

    public static int count=0;

    public Person() {
        count++;
    }

    public Person(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
        count++;
    }

    public static void personsount(){
        System.out.println("当前的人数为"+count);
    }

    public String ageComparison(Person other){
        if (this.age>other.age){
            return this.name+"的年龄比"+other.name+"年龄大"+(this.age-other.age)+"岁";
        }else if (this.age<other.age){
            return other.name+"的年龄比"+this.name+"年龄大"+(other.age-this.age)+"岁";
        }else if (this.age==other.age){
            return other.name+"和"+this.name+"年龄一样大";
        }
        return "";
    }

}
